function displace(event) {

	switch (event.keyCode) {
	case 65:
		A();
		break;
	case 68:
		D();
		break;
	case 83:
		S();
		SHold = true;
		break;
	case 87:
		W();
		break;
	}

}

function SUnhold(event) {
	if (event.keyCode == 83) {
		SHold = false;
		fall.dragable = true;
	}
}

function A() {
	getTopLeft(fall);
	getStartCoor(fall)
	getBottomRight(fall);
	getEndCoor(fall);
	getPointonWall(fall);

	if (fall.stx > 8) {
		if (BarronLeft(fall) == undefined) {
			fall.x -= 21;
		}
	}
}

function D() {
	getTopLeft(fall);
	getStartCoor(fall)
	getBottomRight(fall);
	getEndCoor(fall);
	getPointonWall(fall);

	if (fall.ndx < 210) {
		if (BarronRight(fall) == undefined) {
			fall.x += 21;
		}
	}
};

function S() {
	if (fall.dragable == false) {
		return;
	} else {
		getTopLeft(fall);
		getStartCoor(fall);
		getBottomRight(fall);
		getEndCoor(fall);
		getPointonWall(fall);

		checkIfDead(fall);
		if (fall.y != 37) {
			fall.y += 21;
		}
	}
}

function W() {
	giveValue(stand.arr, fall.arr);
	stand.x = fall.x;
	stand.y = fall.y;

	turnRight(fall.arr);

	getTopLeft(fall);
	getStartCoor(fall);
	moveLeftnTop(fall); //旋转后移到四格的左上角
	if (checkIfI(fall.arr)) {
		moveRight(fall.arr); //如果是I型，向右移一格
	}

	if (fall.stx < 7) {
		fall.x += 21;
	}
	getBottomRight(fall);
	getEndCoor(fall);

	if (fall.ndx > 220 && fall.ndx < 240) {
		fall.x -= 21; //如果超出右边界，向左移
	}
	if (fall.ndx > 240 && fall.ndx < 260) {
		fall.x -= 21 * 2; //如果超出右边界，向左移
	}

	getPointonWall(fall);

	for (var i = fall.stRow; i <= fall.ndRow; i++) {
		for (var j = fall.stCol; j <= fall.ndCol; j++) {
			if ((wstRow + i) >= 0) {
				if ((fall.arr[i][j] == 1) && (wall.arr[wstRow + i][wstCol + j] == 1)) {
					giveValue(fall.arr, stand.arr);
					fall.x = stand.x;
					fall.y = stand.y;
				}
			}
		}
	}
}